<?php
/**
 * Created by PhpStorm.
 * User: ZhangWei
 * Date: 2018/4/23
 * Time: 10:14
 */

namespace App\Logic;


use EasyWeChat\Factory;

class CommonLogic
{

    public static function msg_sec_check($content)
    {
        try {
            $app = Factory::miniProgram(ConfigLogic::getWxConfig());
            $at = $app->access_token->getToken();
            $access_token = $at['access_token'];
            $url = "https://api.weixin.qq.com/wxa/msg_sec_check?access_token=$access_token&content=$content";
            $http = new \GuzzleHttp\Client();
            $req = $http->request('POST', $url, [
                'body' => '{"content":"' . $content . '"}'
            ]);
            $data = $req->getBody()->getContents();
            $obj = json_decode($data);
            if ($obj->errcode == 87014) {
                return false;
            } else {
                return true;
            }
        } catch (\Exception $exception) {
            return true;
        }

    }

}